/**
 * 	 Copyright (c) 2008, 2009 Lukas Zaruba
 * 
 *   This file is part of UniAnalyzer (Universal Analyzer).
 *
 *   UniAnalyzer is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   UniAnalyzer is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with UniAnalyzer. If not, see <http://www.gnu.org/licenses/>.
 */

package net.zarubsys.unianalyzer.dataminers.lpt.gui.parameterObject;

import java.util.ArrayList;
import java.util.List;

import net.zarubsys.unianalyzer.dataminers.lpt.pin.CustomizedPin;
import net.zarubsys.unianalyzer.dataminers.lpt.pin.IPin;
import net.zarubsys.unianalyzer.dataminers.lpt.pin.Pin;
import net.zarubsys.unianalyzer.dataminers.lpt.pin.PinHelper;

public class PreviewData {

	private static final String imageDescriptionPrefix = Messages.getString("PreviewData.imagePrefix"); //$NON-NLS-1$
	
	private final List<Pin> pins;
	private final String imageDescription;
	private final String imageKey;
	
	private static final PreviewData data = new PreviewData(PinHelper.getInstance().getPinsOnOffset(0), Messages.getString("PreviewData.data"), "port.data"); //$NON-NLS-1$
	private static final PreviewData status = new PreviewData(PinHelper.getInstance().getPinsOnOffset(1), Messages.getString("PreviewData.status"), "port.status"); //$NON-NLS-1$
	private static final PreviewData control = new PreviewData(PinHelper.getInstance().getPinsOnOffset(2), Messages.getString("PreviewData.control"), "port.control"); //$NON-NLS-1$
	private static final PreviewData[] previewData = new PreviewData[] {data, status, control};
	
	private PreviewData(List<Pin> pins, String imageDescription, String imageKey) {
		this.pins = pins;
		this.imageDescription = imageDescriptionPrefix + imageDescription;
		this.imageKey = imageKey;
	}
	
	public IPin getPin(int index) {
		return pins.get(index);
	}
	
	public String getImageDescription() {
		return imageDescription;
	}
	
	public static PreviewData getPreviewData(int index) {
		return previewData[index];
	}
	
	public String getImageKey() {
		return imageKey;
	}
	
	public static List<CustomizedPin> createCustomizedPins(PreviewData previewData) {
		List<CustomizedPin> cPins = new ArrayList<CustomizedPin>(8);
		for (int i = 0; i < 8; i++) {
			IPin p = previewData.getPin(i);
			cPins.add(new CustomizedPin(p));
		}
		return cPins;
	}
}

/*
 * $Log$
 */